# # 读文件
# f=open(r'username.json')
# data_discuz=f.read()
# print(data_discuz)
# f.close()
# #第2种方式读文件
# with open(r'username.json') as f:
#     data_discuz=f.read()
#     print(data_discuz)
import csv

# #写入文件
# with open(r'test.txt',mode='w') as f:
#     str='hello world'
#     f.write(str)

# # 读取图片
# with open(r'caomei.png',mode='rb') as f1,open(r'caomei2.png',mode='wb')as f2:
#     data_discuz=f1.read()
#     f2.write(data_discuz)

#忽略首行
with open(r'username.csv') as f:
    f_csv_reader=csv.reader(f)
    next(f_csv_reader)
    for data in f_csv_reader:
        print(data)
#写入
user_feild = ['username', 'password']
user1 = ['test01', '123456']
user2 = ['test02', '123456']
user3 = ['test03', '123456']
user_list = [user_feild, user1, user2, user3]

with open(r'username2.csv', mode='w', newline='')as f:
    f_csv_reader=csv.writer(f)
    f_csv_reader.writerow(user_list)